//go:build wireinject

package main

import (
	"github.com/google/wire"
	rlock "github.com/gotomicro/redis-lock"
	cache2 "jk-time/webook/internal/cache"
	dao2 "jk-time/webook/internal/dao"
	article2 "jk-time/webook/internal/dao/article"
	articleEvents "jk-time/webook/internal/events/article"
	"jk-time/webook/internal/repository"
	"jk-time/webook/internal/service"
	"jk-time/webook/internal/service/sms/metrics"
	"jk-time/webook/internal/web"
	ijwt "jk-time/webook/internal/web/jwt"
	"jk-time/webook/ioc"
	"jk-time/webook/startup"
)

func InitWebServer() *startup.App {
	wire.Build(
		//最基础第三方依赖
		ioc.InitDB,
		ioc.InitRedis,
		ioc.InitKafka,
		ioc.NewSyncProducer,
		ioc.NewConsumer,
		//ioc.InitMongoDB,

		dao2.NewGormUserDAO,
		dao2.NewGormInteractiveDAO,
		//dao.NewGormRetryDAO,
		article2.NewGormArticleDao,
		article2.NewGormArticleAuthorDAO,
		article2.NewGormArticleReaderDAO,

		//dao.NewMongoArticleDao,

		cache2.NewRedisUserCache,
		cache2.NewRedisCodeCache,
		cache2.NewRedisArticleCache,
		cache2.NewRedisInteractiveCache,
		cache2.NewRankingLocalCache,
		cache2.NewRedisRankingCache,

		repository.NewUserRepository,
		repository.NewCodeRepository,
		//repository.NewRetryRepository,
		repository.NewCacheArticleRepository,
		repository.NewArticleAuthorRepository,
		repository.NewCachedArticleReaderRepository,
		repository.NewCacheInteractiveRepository,
		repository.NewCachedRankingRepository,

		service.NewCodeService,
		service.NewUserService,
		service.NewArticleService,
		service.NewInteractiveService,
		service.NewBatchRankingService,

		ijwt.NewRedisJWTHandler,
		web.NewUserHandler,
		web.NewArticleHandler,
		//基于内存
		//ioc.InitSMService,
		metrics.NewPrometheusDecorator,
		ioc.InitGin,
		ioc.InitMiddlewares,
		ioc.InitLogger,

		articleEvents.NewInteractiveKafkaComsumer,
		articleEvents.NewInteractiveKafkaProducer,

		//本地 遠程模式
		ioc.InitIntrClient,
		//etcd
		//ioc.InitIntrClientV1,
		ioc.InitCommentClient,

		ioc.InitRankingJob,
		ioc.InitJobs,

		ioc.InitOAuth2WechatService,
		ioc.InitOAuth2GithubService,

		web.NewOAuth2WechatHandler,
		web.NewOAuth2GithubHandler,

		ioc.Inits3,
		article2.NewS3Dao,

		wire.Struct(new(startup.App), "*"),
		//工具库
		//ioc.InitSnowflake,
		rlock.NewClient,
	)
	return new(startup.App)

}
